package com.example.demo;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
@Slf4j
@SpringBootApplication
@MapperScan(basePackages = {"com.example.demo.**.mapper"})
 // 开启jetcache缓存
//@EnableCreateCacheAnnotation
public class DemoApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(DemoApplication.class,args);
        try {
            Environment env = context.getBean(Environment.class);
            String ip = InetAddress.getLocalHost().getHostAddress();
            String port = env.getProperty("server.port");
            String path = env.getProperty("server.servlet.context-path");
            path = StrUtil.isEmpty(path)?"":path;
            log.info("\n--------------------------------------------------------------\n\t" +
                    "Application is running ! Access URLs:\n\t"+
                    "Local: \t\thttp://localhost:{} {}  /\n\t "+
                    "External: \thttp://{}:{}{}/\n\t" +
                    "Swagger文档: \thttp://{}:{}{}/doc.html\n" +
                    "--------------------------------------------------------------",port,path,ip,port,path,ip,port,path);
        } catch (Exception e) {
            log.error("Application error:",e);
        }
    }

}
